/***************************/
/*Bat dau chuc nang hien thi danh sach*/

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}


function kiemtra()
{
	
	var MaSo = document.getElementById('txtMa').value;
	
	
	var Kq = "";
	
	//Kiem tra ma so
	
	if(MaSo=="")
	{
		Kq += "Ma so khong duoc rong\n";
	}
	

	
	if(isInteger(MaSo)==false)
	{
		Kq += "Ma so khong duoc chua ky tu\n";
	}
	
	return Kq;
}

function themhs()
{


	
	var ChuoiLoi = kiemtra();

    if(ChuoiLoi!="")
    {
        var Chuoi = "Co loi xay ra:\n"
        Chuoi += ChuoiLoi;
        alert(Chuoi);
    }
    else
    {
		
		 
		var MaSo = document.getElementById('txtMa').value;
		var Ten = document.getElementById('txtTen').value;
		var DiaChi = document.getElementById('txtDiaChi').value;
		var DienThoai = document.getElementById('txtDienThoai').value;
		var NgaySinh = document.getElementById('txtNgaySinh').value;
		
		
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		}
		var url="xlthem.php?MaSo=" + MaSo + "&Ten=" + Ten + "&DiaChi=" + DiaChi + "&DienThoai=" + DienThoai  + "&NgaySinh=" + NgaySinh;
		xmlhttp.onreadystatechange=them_stateChanged;
		xmlhttp.open("GET",url,true);
		xmlhttp.send(null);
		
		
	}
	
}
	
function them_stateChanged()
{
	if (xmlhttp.readyState==4)
	{
		var response_stat=xmlhttp.responseText;
			
        if(response_stat == 1)
		{
			alert('Them thanh cong.');
			hienthids();
		}
		else
		{
			alert('Them that bai');
		}
	}
}

/*Ket thuc chuc nang hien thi danh sach**/
/*****/

